package mmc.server.shell.ops.function;

import mmc.server.shell.ShellException;
import mmc.server.shell.ops.Function;

public class Assert extends Function {
	
    public Assert(String text) throws ShellException {
        super(text, "assert", 1, false);
    }

    @Override
    public double execute() {
        throw new RuntimeException(this+" has no return value");
    }
    
    public Object executeComplex(){
    	if(arguments.getCalculatedArgument(0)==0)
    		throw new RuntimeException("Assertion failed: "+text);
    	return null;
    }
    
    public Class<?> getOutputType(){
    	return void.class;
    }
    
    public static String getDescription(){
    	return formatHelpString("assert(op)","assert op==true");
    }
}
